package com.example.demo.service

import com.example.demo.utils.LogUtils
import com.google.gson.Gson
import org.slf4j.LoggerFactory
import org.springframework.messaging.Message
import org.springframework.messaging.MessageHandler
import org.springframework.stereotype.Service

@Service
class MessageReceiverHandler : MessageHandler {

    override fun handleMessage(message: Message<*>) {
        LogUtils.e("${Gson().toJson(message)}")
        val topic = message.headers["mqtt_receivedTopic"].toString()
        val type = topic.substring(topic.lastIndexOf("/") + 1, topic.length)
        LogUtils.e(type)
        LogUtils.e("${message.payload}")
          //      TODO("在此处完成业务代码即可")
    }
}